Apparatus and method for scheduling threads in multi-threading processors

ABSTRACT

An multi-threading processor is provided. The multi-threading processor includes a first instruction fetch unit to receive a first thread and a second instruction fetch unit to receive a second thread. A multi-thread scheduler coupled to the instruction fetch units and a execution unit. The multi-thread scheduler determines the width of the execution unit and the execution unit executes the threads accordingly.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to increasing utilization andoverall performance in multi-threading microprocessors. Moreparticularly, the present invention relates to more effectivelyscheduling threads to optimize a wide in-order processor.

2. Description of the Related Art

In a conventional computer system, microprocessors run several differentprocesses. The computer system utilizes an operating system (OS) todirect the microprocessor to run each of the processes based on priorityand on the process not waiting on an event (e.g., a disk access or auser keypress) to continue. The simplest type of priority system merelydirects the OS to run the programs in sequence (i.e., the last programto be run has the lowest priority). In other systems, the priority of aprogram may be assigned based on other factors, such as the importanceof the program, how efficient it is to run the program, or both. Throughpriority, the OS is then able to determine the order in which programsor software threads or contexts are executed by the processor. It takesa significant amount of time, typically more than the time required toexecute several hundred instructions, for the OS to switch from onerunning process to another running process.

Because of the overhead incurred from each process switch, the OS willonly switch out a process when it knows the process will not be ready torun again for a significant amount of time. However, with the increasingspeed of processors, there are events, which make the processunexecutable for an amount of time that is not long enough to justify anOS-level process switch. When the program is stalled by such an event,such as a cache miss (e.g., when a long latency memory access isrequired), the processor experiences idle cycles for the duration of thestalling event, decreasing the overall system performance. Because newerand faster processors are always being developed, the number of idlecycles experienced by processors is also increasing. Although memoryaccess speed is also being improved, it has not been increased at thesame rate as microprocessor speeds, therefore, processors are spendingan increasing percentage of time waiting for memory to respond.

Recent developments in processor design have allowed formulti-threading, where two or more distinct threads are able to make useof available processor resources. A Simultaneous Multi-Threading (SMT)microprocessor allows multiple threads to share and to compete forprocessor resources at the same time. The threads are scheduledconcurrently and therefore operations from all of the threads progressdown the pipeline simultaneously. If a thread in a SMT system is stalledand waiting for memory, the other threads will continue execution, thusallowing the SMT system to continue executing useful work during a cachemiss.

Because multiple threads are able to issue instructions during eachcycle, a SMT system typically results in a dramatic increase in systemthroughput. However, the performance improvement is subject to certainboundary conditions. The effectiveness of SMT decreases as the number ofthreads increases because the underlying machine resources are limitedand because of the exponential cost increase of inspecting and trackingthe status of each additional thread.

A major problem with scheduling threads in a SMT system occurs whendevelopers attempt to build a SMT system with an in-order machine ratheran out of order machine. As with any threads in any single threadedsystem, the instructions to be executed in a SMT system must be given anorder of execution, determined by whether a particular instruction isdependent on another. For example, if a second instruction depends on aresult from a first instruction, the processor must execute instructionone before executing instruction two.

An out of order machine includes built in hardware that determineswhether or not instructions in a thread are dependent on the result ofanother instruction. If two threads are independent of each other, it isunnecessary to coordinate their scheduling of execution relative to eachother. However, if an instruction is dependent upon another, then theout of order machine schedules the dependent instruction to be executedafter the instruction from which it depends. After examining manyinstructions, the out of order machine is able to create chains ofdependencies for the processor within its execution profile. Because thetwo threads are always independent in a SMT system, the existinghardware in the out of order machine may be extended to schedule thethreads to execute in parallel.

An in-order machine does not include hardware to determine instructiondependency. Instead, instructions are simply presented in memory in thesame order that the compiler or program places them. Therefore, theinstructions must be executed in the same exact order that they wereplaced into memory. Because in-order machines cannot determine thedependency of each instruction, an in-order machine is not able toproperly reorder instructions from different threads in a SMT system. Anadditional in-order scheduling problem arises when the processor is notwide enough and does not have the bandwidth to execute the multiplethreads in parallel.

While SMT systems are able to process more than two threadssimultaneously (some developers have tried to schedule as many as eightthreads at a time), each additional thread requires an increase inmachine cost. For example, a large parallel logic array (PLA) may berequired to coordinate and schedule all of the threads if a SMT systemis complex enough. Therefore, it is often not an efficient use ofprocessing power to execute more than two threads at the same time.Furthermore, such additional overhead is often completely unwarrantedbecause few machines are wide enough or have the resources to supportmore than two active threads.

In view of the foregoing, it is desirable to have a method and apparatusthat provides for a system able to maximize the use of wide processorresources in an in-order machine. In particular, it is desirable to havean in-order SMT system because they are simpler than out of ordermachines, thereby conserving valuable chip space, consuming less power,and generating less heat. It is also desirable to have an in-order SMTsystem with minimal circuit impact.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention will be readily understood by the followingdetailed description in conjunction with the accompanying drawings. Tofacilitate this description, like reference numerals designate likestructural elements.

FIG. 1 illustrates a multithreading system in accordance with oneembodiment of the present invention.

FIG. 2 illustrates the in-order multi-threading processor in accordancewith one embodiment of the present invention.

FIG. 3 is a flow chart of a method for scheduling threads for anin-order multi-threading processor in accordance with one embodiment ofthe present invention.

FIG. 4 illustrates two threads being executed in the bandwidth of anin-order multi-threading processor in accordance with one embodiment ofthe present invention.

DETAILED DESCRIPTION

A method and apparatus for a multi-threading computer system toefficiently schedule threads in a wide in-order processor is provided.In the following description, numerous specific details are set forthin-order to provide a thorough understanding of the present invention.It will be understood, however, to one skilled in the art, that thepresent invention may be practiced without some or all of these specificdetails. In other instances, well known process operations have not beendescribed in detail in-order not to unnecessarily obscure the presentinvention.

In general, to improve the performance of a microprocessor, the numberof transistors that must fit onto a single chip die must be increased.Therefore, the spatial constraint of a single semiconductor chip isperhaps the greatest limiting factor in the speed of a microprocessorand other forms of chips. Developers and engineers constantly strive tofind novel means to fit more transistors onto a chip die. For example,the advent of 0.13 micron semiconductor design and fabrication isspecifically intended to form smaller patterns and features in a chip.The technology would then allow even more transistors and othercircuitry to be placed within the spatial constraint of a single chip.

Overcoming the spatial limitations of a semiconductor chip will onlybecome more and more important in future generations of processors,therefore research is always ongoing to deal with spatial limitations ofthe future. Processor designs that conserve and efficiently utilizespace on a chip will become more and more advantageous over processordesigns that do not. Therefore, the greatest advantage of an in-ordermachine over an out of order machine is simplicity of design. Because anout of order machine is much more complex, it requires a much largernumber of transistors and much more space.

For example, in the Intel processor family, the Pentium processor is anin-order machine with approximately three million transistors. Bycomparison, the Pentium Pro, which is an out of order machine, usesabout six and a half million transistors, requiring much more space thanthe in-order Pentium. Because of the additional transistors, the PentiumPro also requires more power and generates more heat. The presentinvention takes advantage of the existing space conserving design of thein-order machine, which is used in Intel's Itanium Processor Family(IPF) by enabling the in-order platform to support a multi-threadingprocessor.

FIG. 1 is an illustration of a multi-threading computer system 10 inaccordance with one embodiment of the present invention. Multi-threadingcomputer system 10 includes an in-order multi-threading processor 12that is coupled to a memory module 14 and a mass storage device 15.In-order multi-threading processor 12 is preferably a SMT processor.Memory module 14 is typically a form of random access memory (RAM), suchas synchronous dynamic RAM (SDRAM) or Rambus Dynamic RAM (RDRAM).Examples of mass storage device 15 include hard disk drives, floppydrives, optical drives, and tape drives. In multi-threading system 10,programs are loaded from mass storage device 15 into memory module 14and then executed by in-order multi-threading processor 12.

In-order multi-threading processor 12 must execute instructions in theorder the instructions were entered into memory module 14. Therefore,unlike an out of order processor, in-order multi-threading processor 12is unable to create independent chains of execution necessary to extractinstruction level parallelism (ILP) from a single thread. To determinethe dependencies of each of the instructions from the multiple threads,multi-threading computer system 10 relies on a specialized multi-threadscheduler and a compiler to identify sets of independent instructionsand logic to schedule the threads.

FIG. 2 illustrates in-order multi-threading processor 12 in accordancewith one embodiment of the present invention. In-order multi-threadingprocessor 12 includes a pair of instruction fetch units 16 and 18 forthread 1 and thread 2, respectively. Each of the instruction fetch units(IFU) 16 and 18 are uni-directionally coupled to correspondinginstruction decode units (IDU) 20 and 22 for threads 1 and 2. IDUs 20and 22 are then coupled to a multi-thread scheduler 24. In-ordermulti-threading processor 14 also includes an execution unit 26, whichis coupled to multi-thread scheduler 24.

IFUs 16 and 18 read instructions from memory (such as an instructioncache) for threads 1 and 2. Each IFU functions to ensure that theprocessor has enough instruction bandwidth to sustain the highestpossible instruction issue rate. IFUs also operate to predict futureinstruction sequences with a high degree of accuracy. The instructionsare then transmitted to IDUs 20 and 22, which perform operations such asregister renaming and initial dependency checks. IDUs also function topredict branch paths and compute target addresses for branchinstructions.

Instructions from IDU 20 and 22 are then transmitted to multi-threadscheduler 24. Multi-thread scheduler 24 takes into account the availablelocal capacity and prioritizes the incoming instructions from boththread 1 and thread 2, with the goal of maximizing processorutilization. Multi-thread scheduler 24 therefore determines whether ornot execution unit 26 is wide enough to execute thread 1 and thread 2 atthe same time and subsequently decides whether to execute the threads inparallel or in series. Other examples of scheduling policies may includescheduling high load/store processes and low load/store processestogether to yield better system utilization and performance.

Typically, a programmer writes the program in a language such as Pascal,C++ or Java, which is stored in a file called the source code. Theprogrammer then runs the appropriate language compiler to convert thesource code into object code. The object code comprises machine languagethat the processor can execute one instruction at a time. In addition togenerating object code, a compiler may support many other features toaid the programmer. Such features may include automatic allocation ofvariables, arbitrary arithmetic expressions, variable scope,input/output operations, higher-order functions and portability ofsource code.

In the present invention, the compiler explicitly describes blocks ofindependent operations to the in-order machine so that may be executedin parallel. In contrast, a compiler for earlier machines was notcapable of describing independent instructions. Instead, hardware wasrequired to determine independent instructions at run time. Therefore,in the present invention, the task of generating instruction levelparallelism is accomplished statically at compile time rather thandynamically at run time.

This thread dispersal of the compiler of the present invention forin-order machines thus motivates the development of wide in-ordermachines that can execute many instructions simultaneously. In addition,to efficiently utilize the capabilities of a wide in-order machine, themachine must also be able to schedule multiple threads when the compilercannot find enough ILP in a single thread to fully occupy the machine asdescribed above with regard to multi-thread scheduler 24.

FIG. 3 is a flow chart of a method 28 for scheduling threads for anin-order multi-threading processor in accordance with one embodiment ofthe present invention. Method 28 begins at a block 30 where thread 1 andthread 2 are fetched. A block 32 determines whether the in-ordermulti-threading processor is wide enough to execute both threads 1 and 2in parallel. The width of threads 1 and 2 are examined during each cycleand then compared to the width of the processor. If the in-ordermulti-threading processor is wide enough to execute all of theinstructions in threads 1 and 2, then both threads 1 and 2 are executedin parallel in a block 34. If the in-order multi-threading processor isnot wide enough to execute both threads, then the threads are executedin series in blocks 36 and 38.

FIG. 4 illustrates two threads being executed in the bandwidth of anin-order multi-threading processor in accordance with one embodiment ofthe present invention. As shown, an in-order multi-threading processorusually has enough width to execute threads 1 and 2 in parallel. This isbecause the compiler can usually find instructions from one thread thatare only use half of the machine. The individual instructions in threads1 and 2 are called syllables 40 and 42, which are organized cycle bycycle based on whether a particular syllable 40 is dependent upon theresult of another. Using method 28 as described above, the threads areanalyzed to determine if syllables 40 from thread 1 and syllables 42from thread 2 fit in the width of the in-order multi-threadingprocessor. If the syllables from both threads cannot be executed inparallel, then each thread must be executed in series.

Referring to FIG. 4, lines A, B, C, D, and G illustrate examples of anin-order multi-threading processor executing threads 1 and 2 inparallel. However, in line E, thread 1 included four syllables 40 andthread 2 included three syllables 42, proving to be too wide for thein-order multi-threading processor. The syllables 42 for thread 2 werethen deferred until the next cycle represented by line F. Then in lineG, the in-order multi-threading processor was again wide enough toexecute both threads 1 and 2, therefore parallel operations resumed.

While multi-thread scheduler 24 in FIG. 2 is programmed to schedule onlytwo threads for processing, it is well known in the art that amulti-thread scheduler may be configured to schedule additional threads.Each additional thread being scheduled by in-order multi-threadingprocessor 12 would also require a corresponding instruction fetch andinstruction decode unit. While such a system would be able to processmore than two threads simultaneously, each additional thread requires anexponential increase in machine cost, such as a large parallel logicarray (PLA), to coordinate and schedule all of the threads.

Therefore, adding additional threads to the present invention couldeliminate the advantage of multi-threading. In fact, the per-thread costis even larger for an in-order machine than for an out-of-order machine.With the current configuration of in-order multi-threading processor 12,it is not an efficient use of processing power to execute more than twothreads at the same time, particularly because the processor is notcurrently wide enough to support more than two threads in parallel.

In summary, the present invention provides for an apparatus and methodfor scheduling multiple threads for a simultaneous multi-threadingin-order processor. Despite the fact that out of order dynamic machineshave the advantage of possessing an existing structure to schedulethreads and create independent chains of execution in a multi-threadingprocessor, in-order static machines possess many desirable architecturalcharacteristics, such as simplicity of design. In-order machines arealso easier to design than out of order machines because in-ordermachines are less complex.

Another advantage of an in-order machine is the conservation of spaceand power. Although out of order machines offer additional features inreturn for the additional design effort, the complexity of thearchitecture is a disadvantage because it requires much more of thelimited space on a semiconductor chip. As microprocessor speeds continueto increase, the number of transistors that must fit into asemiconductor chip die must also increase, a process that could lead tooverheating. The present invention therefore not only provides forutilizing an in-order machine for multi-threading processes, but alsofor conserving power and chip space, allowing much more flexibility forfuture microprocessor designs.

Other embodiments of the invention will be appreciated by those skilledin the art from consideration of the specification and practice of theinvention. Furthermore, certain terminology has been used for thepurposes of descriptive clarity, and not to limit the present invention.The embodiments and preferred features described above should beconsidered exemplary, with the invention being defined by the appendedclaims.

1. A multi-threading processor, comprising: a first instruction fetchunit to receive a first thread and a second instruction fetch unit toreceive a second thread; an execution unit to execute said first threadand said second thread; and a multi-thread scheduler coupled to saidfirst instruction fetch unit, said second instruction fetch unit, andsaid execution unit, wherein said multi-thread scheduler is to determinewhether the width of said execution unit.
 2. A multi-threading processoras recited in claim 1, wherein the multi-thread scheduler unitdetermines whether the execution unit is to execute the first thread andthe second thread in parallel depending on the width of the executionunit.
 3. A multi-threading processor as recited in claim 2, wherein themulti-thread processor is an in-order processor.
 4. A multi-threadingprocessor as recited in claim 3, wherein the execution unit executes thefirst thread and the second thread in parallel.
 5. A multi-threadingprocessor as recited in claim 3, wherein the execution unit executes thefirst thread and the second thread in series.
 6. A multi-threadingprocessor as recited in claim 3, wherein the first thread and the secondthread are compiled to have instruction level parallelism.
 7. Amulti-threading processor as recited in claim 6, further comprising: afirst instruction decode unit coupled between the first instructionfetch unit and the multi-thread scheduler; and a second instructiondecode unit coupled between the second instruction fetch unit and themulti-thread scheduler.
 8. A multi-threading processor as recited inclaim 4, wherein the execution unit executes only two threads inparallel.
 9. A method for scheduling threads in a multi-threadingprocessor, comprising: determining whether said multi-threadingprocessor is wide enough to execute a first thread and a second threadin parallel; and executing said first thread and said second thread inparallel if said multi-threading processor is wide enough to execute thefirst thread and the second thread in parallel.
 10. A method forscheduling threads as recited in claim 9, further comprising executingthe first thread and the second thread in series if said multi-threadingprocessor is not wide enough.
 11. A method for scheduling threads asrecited in claim 10, wherein the multi-threading processor is anin-order processor.
 12. A method for scheduling threads as recited inclaim 11, further comprising compiling the first thread and the secondthread, wherein the first thread and the second thread have instructionlevel parallelism.
 13. A method for scheduling threads as recited inclaim 12, wherein the multi-threading processor executes only twothreads in parallel.
 14. A method for scheduling threads as recited inclaim 13, further comprising: fetching the first thread and the secondthread; and decoding the first thread and the second thread.
 15. A setof instructions residing in a storage medium, said set of instructionscapable of being executed by a processor for searching data stored in amass storage device comprising: determining whether said multi-threadingprocessor is wide enough to execute a first thread and a second threadin parallel; and executing said first thread and said second thread inparallel if said multi-threading processor is wide enough to execute thefirst thread and the second thread in parallel.
 16. A method forscheduling threads as recited in claim 15, further comprising executingthe first thread and the second thread in series if said multi-threadingprocessor is not wide enough.
 17. A method for scheduling threads asrecited in claim 16, wherein the multi-threading processor is anin-order processor.
 18. A method for scheduling threads as recited inclaim 17, further comprising compiling the first thread and the secondthread, wherein the first thread and the second thread have instructionlevel parallelism.
 19. A method for scheduling threads as recited inclaim 18, wherein the multi-threading processor executes only twothreads in parallel.
 20. A method for scheduling threads as recited inclaim 19, further comprising: fetching the first thread and the secondthread; and decoding the first thread and the second thread.